Trigger on script completion

Dear experienced Mates,

is there any possibility to signalise a script termination to another script?

The situation is the following. There is a script A which calls script B via

if ( fileExists_(B) && confirm ("You want to run B now ?", msgQuery) ) eval_("#include <">")

 


But after this call I have to continue with my main script A.
How could I force A to wait until B ends?

Thanks alot:
vasgyuszi

 


vasgyuszi - Mon May 09 12:20:10 EDT 2011

Re: Trigger on script completion
vasgyuszi - Mon May 09 12:26:01 EDT 2011

The calling line appears faulty after the include term, but I'm using it in correct form.

Re: Trigger on script completion
llandale - Mon May 09 15:33:38 EDT 2011

the current DXL context will wait for the eval_ to finish before continuing. Perhaps B can leave A a message in a file as to its status.

Re: Trigger on script completion
vasgyuszi - Mon May 09 17:25:26 EDT 2011

llandale - Mon May 09 15:33:38 EDT 2011
the current DXL context will wait for the eval_ to finish before continuing. Perhaps B can leave A a message in a file as to its status.

"the current DXL context will wait for the eval_ to finish before continuing. "

Obviously doesn't, because the next following infoBox after the eval_ line appears in the same time as the script B had start.

Meanwhile I have an idea:

1) Script B creates a formal module with a known name and to a known path (project root for example)
2) Script B closes it.
3) Script A sets a trigger to observe the creation event of this model with well known parameters
4) If the event happened, script A deletes the formal module in order to clean up
5) Script A continues its run

Could this work, what's your opinion?

Best regards,
vasgyuszi

Re: Trigger on script completion
Mathias Mamsch - Mon May 09 17:52:27 EDT 2011

vasgyuszi - Mon May 09 17:25:26 EDT 2011
"the current DXL context will wait for the eval_ to finish before continuing. "

Obviously doesn't, because the next following infoBox after the eval_ line appears in the same time as the script B had start.

Meanwhile I have an idea:

1) Script B creates a formal module with a known name and to a known path (project root for example)
2) Script B closes it.
3) Script A sets a trigger to observe the creation event of this model with well known parameters
4) If the event happened, script A deletes the formal module in order to clean up
5) Script A continues its run

Could this work, what's your opinion?

Best regards,
vasgyuszi

Louie is right, eval_ WILL wait for the script to end before it continues. Remember that DOORS can only run one DXL at a time. So unless the eval_ code ends, no other DXL script will run. However if you start up a GUI with show or realize in eval, then the GUI will show up and the DXL will end and your calling script will continue after the eval. The GUI however will stay alive and be fed from DOORS from the GUI message loop.

Please don't implement a semaphore by creating a temporary module ;-) I am sure we can find a more elegant solution together. Do you want to elaborate on what you are trying to do?

Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Trigger on script completion
vasgyuszi - Tue May 10 00:24:23 EDT 2011

Mathias Mamsch - Mon May 09 17:52:27 EDT 2011
Louie is right, eval_ WILL wait for the script to end before it continues. Remember that DOORS can only run one DXL at a time. So unless the eval_ code ends, no other DXL script will run. However if you start up a GUI with show or realize in eval, then the GUI will show up and the DXL will end and your calling script will continue after the eval. The GUI however will stay alive and be fed from DOORS from the GUI message loop.

Please don't implement a semaphore by creating a temporary module ;-) I am sure we can find a more elegant solution together. Do you want to elaborate on what you are trying to do?

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Thanks Mathias!

I'm sure, the introduced concept miss any elegancy, but could work.

You have right, the script B has its GUI starting with show and it appears also.
Why I thought eval_ don't wait: I got script B's GUI (waiting for usr inputs) and also got script A's infoBox placed after the eval_ line. I stopped here my activities for further investigation but today I'll try to let run script B with the appearing GUI.But I'll avoid to confuse the user by getting both GUIs at same time (one from script B and another from script A) beacuse the user could decide to click on A's GUI and mess up the execution sequence.

Thanks for Your advices!

Bestr regards,
vasgyuszi

Re: Trigger on script completion
vasgyuszi - Tue May 10 04:58:59 EDT 2011

vasgyuszi - Tue May 10 00:24:23 EDT 2011
Thanks Mathias!

I'm sure, the introduced concept miss any elegancy, but could work.

You have right, the script B has its GUI starting with show and it appears also.
Why I thought eval_ don't wait: I got script B's GUI (waiting for usr inputs) and also got script A's infoBox placed after the eval_ line. I stopped here my activities for further investigation but today I'll try to let run script B with the appearing GUI.But I'll avoid to confuse the user by getting both GUIs at same time (one from script B and another from script A) beacuse the user could decide to click on A's GUI and mess up the execution sequence.

Thanks for Your advices!

Bestr regards,
vasgyuszi

Now I had experienced and let run the scripts:

1) A is running
2) A arrives the eval_ call of B
3) B 's GUI appears BUT A 's next line will be executed
4) Only A could continue because only *A*'s GUI is alive
5) After completion of A can be attached B 's GUI by the user .

This isn't what I want... I would suspend A 's execution until B ends.

What can I do?

Thanks alot,
vasgyuszi

Re: Trigger on script completion
Mathias Mamsch - Tue May 10 05:03:10 EDT 2011

vasgyuszi - Tue May 10 04:58:59 EDT 2011
Now I had experienced and let run the scripts:

1) A is running
2) A arrives the eval_ call of B
3) B 's GUI appears BUT A 's next line will be executed
4) Only A could continue because only *A*'s GUI is alive
5) After completion of A can be attached B 's GUI by the user .

This isn't what I want... I would suspend A 's execution until B ends.

What can I do?

Thanks alot,
vasgyuszi

The easiest way to do this would be, to replace show with block. Just run your script B using:
 

string sCode = "void show(DB x) { block x; release x; destroy x }
#include <...your b file...>"
eval_ sCode

 


This will make the GUI of B call block and therefore suspend A. Regards, Mathias

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Trigger on script completion
vasgyuszi - Tue May 10 08:39:45 EDT 2011

Mathias Mamsch - Tue May 10 05:03:10 EDT 2011

The easiest way to do this would be, to replace show with block. Just run your script B using:
 

string sCode = "void show(DB x) { block x; release x; destroy x }
#include <...your b file...>"
eval_ sCode

 


This will make the GUI of B call block and therefore suspend A. Regards, Mathias

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Thanks alot, Mathias!

It works perfectly, and last but not least: looks very elegant.

Best regards,
vasgyuszi

Re: Trigger on script completion
Mathias Mamsch - Tue May 10 09:14:31 EDT 2011

vasgyuszi - Tue May 10 08:39:45 EDT 2011
Thanks alot, Mathias!

It works perfectly, and last but not least: looks very elegant.

Best regards,
vasgyuszi

Heh ... elegancy is not only about the looks ;-) its about behaviour too ... And this one behaves very calmly without creating wild modules ... Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Trigger on script completion
llandale - Tue May 10 10:07:45 EDT 2011

vasgyuszi - Mon May 09 17:25:26 EDT 2011
"the current DXL context will wait for the eval_ to finish before continuing. "

Obviously doesn't, because the next following infoBox after the eval_ line appears in the same time as the script B had start.

Meanwhile I have an idea:

1) Script B creates a formal module with a known name and to a known path (project root for example)
2) Script B closes it.
3) Script A sets a trigger to observe the creation event of this model with well known parameters
4) If the event happened, script A deletes the formal module in order to clean up
5) Script A continues its run

Could this work, what's your opinion?

Best regards,
vasgyuszi

Run the following, eval_ finishes before the code after the call starts:

string    DxlCode = "infoBox(\"Hello from DxlCode\")\nreturn_(\"xyz\")"
string  Result  = eval_(DxlCode)
infoBox("Hello after eval_, code:\n" DxlCode "\nResult: " Result)


Notice that you use command "return_(string)" inside the eval code in order to send a result back to the calling script. Understand that "return_" does NOT 'return' in the normal sense, it just means "set the return string", you can have several 'return_'s coded.

return_("OK")
if (something went wrong) then return_("Bad")

Mathias is right that if the DxlCode issues a 'show' then that counts as "finished" and the code after the eval_ will start up. The code does NOT start up again when the eval_ dialog is closed. Doesn't work for 'realize' nor 'block' however.

Mathias is also right, what the heck are you trying to do?

 

 

  • Louie


Sure glad you came up with the Module semaphore thing first because I was going to suggest something like that, then Mathias would have correctly slammed me!

 

 

Re: Trigger on script completion
llandale - Tue May 10 10:15:33 EDT 2011

vasgyuszi - Mon May 09 17:25:26 EDT 2011
"the current DXL context will wait for the eval_ to finish before continuing. "

Obviously doesn't, because the next following infoBox after the eval_ line appears in the same time as the script B had start.

Meanwhile I have an idea:

1) Script B creates a formal module with a known name and to a known path (project root for example)
2) Script B closes it.
3) Script A sets a trigger to observe the creation event of this model with well known parameters
4) If the event happened, script A deletes the formal module in order to clean up
5) Script A continues its run

Could this work, what's your opinion?

Best regards,
vasgyuszi

Here's something to play with. Change 'block' to 'show' and it behaves differently

string    DxlCode = 
"void clbk(DB db)
{  infoBox(\"Hellow from DxlCode clbk()\")
   return_(\"In clbk\")
}
DB db = create(\"Hello\")
apply(db, \"Say Hello\", clbk)
realize(db)
return_(\"Generated\")
infoBox(\"Before block\")
block(db)
destroy(db)
infoBox(\"after block\")
"  // end string DxlCode
string  Result  = eval_(DxlCode)
 
DB  db = create("Results")
DBE dbe = text(db, "", "Hello after eval_, code:\n" DxlCode "\nResult: " Result, 240, 250, true)
show(db)

Re: Trigger on script completion
vasgyuszi - Tue May 10 13:56:24 EDT 2011

llandale - Tue May 10 10:15:33 EDT 2011

Here's something to play with. Change 'block' to 'show' and it behaves differently

string    DxlCode = 
"void clbk(DB db)
{  infoBox(\"Hellow from DxlCode clbk()\")
   return_(\"In clbk\")
}
DB db = create(\"Hello\")
apply(db, \"Say Hello\", clbk)
realize(db)
return_(\"Generated\")
infoBox(\"Before block\")
block(db)
destroy(db)
infoBox(\"after block\")
"  // end string DxlCode
string  Result  = eval_(DxlCode)
 
DB  db = create("Results")
DBE dbe = text(db, "", "Hello after eval_, code:\n" DxlCode "\nResult: " Result, 240, 250, true)
show(db)

Thanks guys, again! I do learn always something useful and tricky things from you!